package pers.xiaojun.boot.module.infra.api.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import pers.xiaojun.boot.module.infra.dao.entity.ConfigDO;
import pers.xiaojun.boot.module.infra.service.config.ConfigService;

/**
 * 参数配置API实现类
 *
 * @author xiaojun
 * @since 2025-11-09
 */
@Service
@RequiredArgsConstructor
@Log4j2
public class ConfigApiImpl implements ConfigApi {

    private final ConfigService configService;

    @Override
    public String getConfigValueByKey(String configKey) {
        ConfigDO config = configService.getConfigByKey(configKey);
        if (config == null) {
            log.error("[ConfigApi] 参数配置键值 {} 不存在", configKey);
            return null;
        }
        return config.getValue();
    }

}
